//表单验证
layui.form.verify({
    password: [ // 密码
      /^[\S]{6,12}$/,
      '密码是6到10位, 不能有空格'
    ],
    // 新密码 
    diff :function (value) {
         return (value ===$('input[name="oldPwd" ]').val()) && '新密码不能与原密码相同'
    },
    same:function (value) {
         return (value !== $('input[name="newPwd"]').val()) && '确认密码要与新密码相同'
    }
  });

  //重置密码
  $('form').on('submit',(e)=>{
    e.preventDefault()
    axios.post('http://api-breakingnews-web.itheima.net/my/updatepwd',$('form').serialize(),{headers:{Authorization:localStorage.getItem('token')}}).then(({data:res})=>{
        console.log(res);
        layer.msg(res.message)
        if(res.status === 0){
            localStorage.removeItem('token')
            //利用大网页去跳转
            window.parent.location.href = '/login.html'
        }
    })
})